<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CrateShopProductTable extends Migration
{
    public function up()
    {
        //产品列表
        Schema::create('shop_product', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('category_id')->comment('分类ID');
            $table->unsignedInteger('brand_id')->default(0)->comment('品牌ID');
            $table->string('title')->comment('标题');
            $table->string('main_img')->comment('主图');
            $table->unsignedInteger('product_images_id')->comment('产品详情图ID');
            $table->unsignedInteger('product_specs_id')->default(0)->comment('产品规格ID');    // 0 单品 无属性
            $table->unsignedDecimal('sale_price',10,2)->comment('销售价格');
            $table->unsignedDecimal('original_price',10,2)->default(0)->comment('零售价(原价)');
            $table->unsignedDecimal('purchase_price',10,2)->default(0)->comment('进货价格');
            $table->unsignedInteger('stock')->comment('库存数量');
            $table->unsignedInteger('sales')->default(0)->comment('销量');
            $table->mediumText('detail')->comment('详情页');
            $table->tinyInteger('sort')->default(50)->comment('排序');
            $table->boolean('status')->default(true)->comment('状态 0下架,1上架 (默认true 上架)');
            $table->unsignedInteger('freight_id')->default(0)->comment('运费规则ID  默认0');
            $table->timestamps();
        });
    }
    public function down()
    {
        Schema::dropIfExists('shop_product');
    }
}
